from enum import Enum, unique
import pandas as pd


class InstrumentType(Enum):
    Stock = 0
    Future = 1
    Option = 2
    Bond = 3
    Index = 4
    ETF = 5
    MutualFund = 6
    FutureIndex = 7


#
def Determin_Instrument_Type(database, symbol):
    instrument_types = ["index", "mutualfund", "future", "stock"]
    for instrument_type in instrument_types:
        if instrument_type == "future":
            df = database.Get_Instruments_DataFrame(instrument_type + "index", filter=[["symbol", symbol]], projection=["symbol"])
        else:
            df = database.Get_Instruments_DataFrame(instrument_type, filter=[["symbol", symbol]], projection=["symbol"])
        if len(df) > 0:
            return instrument_type
    return None


def Add_Instrument_Type_Column(database, df):
    df_instrument_type = database.Get_Instruments_DataFrame(instrument_type=None, projection=["symbol", "asset_type", "instrument_type"])
    df = pd.merge(df, df_instrument_type, on="symbol", how="left")
    return df


def JT2_Instrument_Type():
    pass